package com.lansea.wms.model;

import com.lansea.wms.entity.ValidClass;
import com.lansea.wms.model.base.BaseWareUserTime;
import com.lansea.wms.util.DateUtil;
import com.lansea.wms.validate.CodeValidate;
import com.lansea.wms.validate.RemarkValidate;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Repository;

import javax.validation.constraints.Min;
import java.util.Date;
@Data
@Repository
@ApiModel(value = "StockTrans", description = "移位记录")
public class StockTrans extends BaseWareUserTime {

    @Min(value = 1, message = "id 非法", groups = {ValidClass.EditForm.class})
    private Integer id;

    @CodeValidate(message = "单号长度必须为 2-40", groups = {ValidClass.EditForm.class})
    private String number;
    private Integer status;

    @RemarkValidate
    private String remark;

    private Integer warehouseTid;
    private Integer reservoirTid;

    @Min(value = 1, message = "请选择源货架")
    private Integer stockId;

    @Min(value = 1, message = "请选择目标货架")
    private Integer stockTid;

    private String warehouseNameTo;
    private String reservoirNameTo;
    private String stockNameTo;

    private String warehouseCodeTo;
    private String reservoirCodeTo;
    private String stockCodeTo;

    private Integer moveCount;

    private Integer approveUid;

    @DateTimeFormat(pattern = DateUtil.DATE_TIME_FORMAT)
    private Date approveTime;

    private String rejectRemark;

    private String approveUserName;


    /**
     * 是否允许提交
     *
     * @return
     */
    public boolean canSubmit() {
        if (status == null) {return false;}
        return status == 1 || status == 4;
    }

    /**
     * 是否允许审批
     *
     * @return
     */
    public boolean canApprove() {
        if (status == null) {return false;}
        return status == 2;
    }

    /**
     * 是否允许完成
     *
     * @return
     */
    public boolean canFinish() {
        if (status == null) {return false;}
        return status == 3;
    }



}
